using System.Data;
using System.Data.SqlClient;
using VanTaiProperty;
namespace VanTaiData
{
    public class clsTMDistrictController
    {
        private clsConnect cls = new clsConnect();

        #region Getdata
        public DataTable BindGirdTMDistrict(string keywords)
        {
            return cls.Search("sp_TMDistrict", "@KeyWords", keywords);
        }
        public DataTable BindGirdTMDistrictDetail(int id)
        {
            return cls.LayDuLieuParameter("sp_TMDistrict_Detail", "@District_ID", id);
        }
        public DataTable BindGirdTMDistrictFilterTinh(int id)
        {
            return cls.LayDuLieuParameter("sp_TMDistrict_FilterTinh", "@Province_ID", id);
        }
        public DataTable BindGridTMDistrictDropdownlist(int id)
        {
            return cls.LayDuLieuParameter("sp_TMDistrict_Dropdownlist", "@Province_ID", id);
        }
        #endregion

        #region Insert
        public bool InsertTMDistrict(clsTMDistrictProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@District_Alias", data.District_Alias);
            cls.AddParameter("@District_Name", data.District_Name);
            cls.AddParameter("@Province_ID", data.Province_ID);
            cls.AddParameter("@District_Note", data.District_Note);
            cls.AddParameter("@District_MaCha", data.District_MACHA);
            cls.AddParameter("@District_NameE", data.District_NameE);
            cls.AddParameter("@District_NameC", data.District_NameC);
            cls.ExecuteNonQuery("sp_TMDistrict_Insert");
            return true;
        }
        #endregion

        #region Update
        public bool UpdateTMDistrict(clsTMDistrictProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@District_ID", data.District_ID);
            cls.AddParameter("@District_Alias", data.District_Alias);
            cls.AddParameter("@District_Name", data.District_Name);
            cls.AddParameter("@Province_ID", data.Province_ID);
            cls.AddParameter("@District_Note", data.District_Note);
            cls.AddParameter("@District_MaCha", data.District_MACHA);
            cls.AddParameter("@District_NameE", data.District_NameE);
            cls.AddParameter("@District_NameC", data.District_NameC);
            cls.ExecuteNonQuery("sp_TMDistrict_Update");
            return true;
        }
        #endregion

        #region Delete
        public bool DeleteTMDistrict(int id)
        {
            cls.Delete("sp_TMDistrict_Delete", "@District_ID", id);
            return true;
        }
        #endregion
    }
}